package com.ruoyi.busi.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.busi.domain.dao.BizHolidayDao;
import com.ruoyi.busi.mapper.BizHolidayDaoMapper;
import com.ruoyi.busi.service.IBizHolidayDaoService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 休假业务Service业务层处理
 *
 * @author ruoyi
 * @date 2025-09-17
 */
@Service
public class BizHolidayDaoServiceImpl extends ServiceImpl<BizHolidayDaoMapper, BizHolidayDao> implements IBizHolidayDaoService {
    @Autowired
    private BizHolidayDaoMapper BizHolidayDaoMapper;

    /**
     * 查询休假业务
     *
     * @param id 休假业务主键
     * @return 休假业务
     */
    @Override
    public BizHolidayDao selectBizHolidayDaoById(String id) {
        return BizHolidayDaoMapper.selectBizHolidayDaoById(id);
    }

    /**
     * 查询休假业务列表
     *
     * @param BizHolidayDao 休假业务
     * @return 休假业务
     */
    @Override
    public List<BizHolidayDao> selectBizHolidayDaoList(BizHolidayDao BizHolidayDao) {
        return BizHolidayDaoMapper.selectBizHolidayDaoList(BizHolidayDao);
    }

    /**
     * 新增休假业务
     *
     * @param BizHolidayDao 休假业务
     * @return 结果
     */
    @Override
    public int insertBizHolidayDao(BizHolidayDao BizHolidayDao) {
        BizHolidayDao.setCreateTime(DateUtils.getNowDate());
        return BizHolidayDaoMapper.insertBizHolidayDao(BizHolidayDao);
    }

    /**
     * 修改休假业务
     *
     * @param BizHolidayDao 休假业务
     * @return 结果
     */
    @Override
    public int updateBizHolidayDao(BizHolidayDao BizHolidayDao) {
        BizHolidayDao.setUpdateTime(DateUtils.getNowDate());
        return BizHolidayDaoMapper.updateBizHolidayDao(BizHolidayDao);
    }

    /**
     * 批量删除休假业务
     *
     * @param ids 需要删除的休假业务主键
     * @return 结果
     */
    @Override
    public int deleteBizHolidayDaoByIds(String[] ids) {
        return BizHolidayDaoMapper.deleteBizHolidayDaoByIds(ids);
    }

    /**
     * 删除休假业务信息
     *
     * @param id 休假业务主键
     * @return 结果
     */
    @Override
    public int deleteBizHolidayDaoById(String id) {
        return BizHolidayDaoMapper.deleteBizHolidayDaoById(id);
    }

    @Override
    public int saveBizHolidayDao(BizHolidayDao bizHoliday) {
        if (StringUtils.isEmpty(bizHoliday.getId())) {
            this.baseMapper.insert(bizHoliday);
            return 1;
        }
        BizHolidayDao holidayDao = this.baseMapper.selectById(bizHoliday.getId());
        if (holidayDao == null) {
            this.baseMapper.insert(bizHoliday);
            return 1;
        }
        this.baseMapper.updateById(bizHoliday);
        return 1;
    }

    @Override
    public int submitBizHolidayDao(BizHolidayDao bizHoliday) {
        this.saveBizHolidayDao(bizHoliday);
        return 0;
    }
}